const mongoose=require('mongoose')
const bcrypt=require('bcryptjs')
const {Schema,model}=mongoose
const userSchema=new Schema({
    username:{type:String,unique:true,required:true},
    password:{
        type:String,required:true,
        set(val){
            return bcrypt.hashSync(val,10)//密码加密
        }
    },
    name:{type:String,required:true},
    role:{type:String,default:0, required:true}, //身份 1是管理员，0是普通用户
})
const UserModel=model('user',userSchema)
module.exports=UserModel